<?php
	/* 
		激活会员卡
	*/
	global $_W,$_GPC;	
	if($_W['role'] && $_W['isajax']){
		require_once MODULE_ROOT.'/mii/class/membercard.class.php';	
		$mid = $_GPC['mid'];
		$name = $_GPC['name'];
		$phone = $_GPC['phone'];
		$on =  new memberNumber($mid);
		$mcard_on = $on->code_on();		
		if(!empty($mid) && !empty($name) && !empty($phone)){
			$ismcard = pdo_get('mii_ang_mcard',array('uid'=>$mid),array('id'));
			$data =  array();
			$data = array('uniacid'=>$_W['uniacid'],'uid'=>$mid,'name'=>$name,'phone'=>$phone,'balance'=>'0.00','consumption'=>'0.00','mcard_on'=>$mcard_on,'activation'=>'1','status'=>'1');
			if($ismcard){
				$up = pdo_update('mii_ang_mcard',array('activation'=>'1'),array('uid'=>$mid));
				if($up){exit(json_encode(array('status'=>1,'msg'=>'激活成功')));}else{
					exit(json_encode(array('status'=>-1,'msg'=>'激活写入失败')));
				}
			}else{
				$ins = pdo_insert('mii_ang_mcard',$data);
				if($ins){exit(json_encode(array('status'=>1,'msg'=>'激活成功')));}else{exit(json_encode(array('status'=>-1,'msg'=>'激活写入失败')));}
			}		

		}else{
			exit(json_encode(array('status'=>-1,'msg'=>'缺失必要参数'.$mid.$name.$phone)));
		}

	}else{
		exit(json_encode(array('status'=>-1,'msg'=>'没有操作权限')));
	}	




?>